package com.tjbank.cssys.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import com.tjbank.cssys.web.config.GetUserCodeFromToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.tjbank.cssys.framework.base.api.BaseController;
import com.tjbank.cssys.framework.base.api.Response;
import com.tjbank.cssys.api.LoginService;
import com.tjbank.cssys.dto.LoginDTO;

import java.util.Date;
import java.util.UUID;


/**
 * @menu: /登录
 * @author -- lijiangtao
 * @date: 2020年5月3日 下午3:51:32
 */
@RestController
public class LoginController extends BaseController {

    @Autowired
    private LoginService loginService;
    @Autowired
    private HttpServletRequest request;
     private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
    /**
     * login
     *
     * @param loginDto
     * @return
     * @throws Exception
     * @status done 
     * @author -- lijiangtao 2020年5月3日 下午4:11:24
     */
    @PostMapping("/login")
    @SuppressWarnings("unchecked")
    public Response<Object> login(@RequestBody @Valid LoginDTO loginDTO , HttpServletRequest request) throws Exception {



        return this.success(loginService.login(loginDTO));
    }

    /**
     * 判断 用户是否需要修改密码。。
     * @param userid
     * @return
     */
    @GetMapping("/confirm/updatePwd")
    public Response<Object> isFirstOrThirdMonth(String userid ,HttpServletRequest request)  throws Exception {



        return this.success(loginService.judgeLogin(userid));
    }
    @GetMapping("/api/loginout")
    public Response<Object> loginOut(String userCode){
       return  this.success(loginService.loginOut(userCode));
    }
}
